<template>
  <img :src="getCurrentPng(type, nameSuffix)" />
</template>

<script setup lang="ts">

import { isOffice } from '@/utils/util'
import knowledgePng from '@/assets/images/common/knowledge.png'
import wenjianjiaPng from '@/assets/images/common/wenjianjia.png'
import wordPng from '@/assets/images/common/word.png'
import excelPng from '@/assets/images/common/keowledgeExcel.png'
import mapPng from '@/assets/images/common/map.png'
import liuchengPng from '@/assets/images/common/keowledgeLiucheng.png'
import gifPng from '@/assets/images/common/gif.png'
import tupianPng from '@/assets/images/common/keowledgeTupian.png'
import textPng from '@/assets/images/common/text.png'
import pptPng from '@/assets/images/common/keowledgePpt.png'
import csvPng from '@/assets/images/common/csv.png'
import pdfPng from '@/assets/images/common/keowledgePdf.png'
import dianzishuPng from '@/assets/images/common/keowledgeDianzishu.png'
import svgPng from '@/assets/images/common/svg.png'
import psPng from '@/assets/images/common/ps.png'
import visPng from '@/assets/images/common/vis.png'
import ofdPng from '@/assets/images/common/ofd.png'
import yasuoPng from '@/assets/images/common/keowledgeYasuo.png'
import cadPng from '@/assets/images/common/cad.png'
import weizhiPng from '@/assets/images/common/keowledgeWeizhi.png'
import mdPng from '@/assets/images/common/md.png'
import urlPng from '@/assets/images/common/keowledgURL.png'
import txtPng from '@/assets/images/common/iconTxt.png'
import luckysheetPng from '@/assets/images/common/luckysheet.png'
import xmindPng from '@/assets/images/common/keowledgeXMIND.png'
import mp3Png from '@/assets/images/common/mp3.png'
import videoPng from '@/assets/images/common/keowledgeShipin.png'

const emit = defineEmits([""])
defineProps({
  type: {
    type: String,
    default: ""
  },
  nameSuffix: {
    type: String,
    default: ""
  }
})
function getCurrentPng(type: string | undefined, nameSuffix: string) {
  let src = ""
  if (isOffice(type) || type == 'document_upload') {
    if (["cda", "wav", "mp3", "aif", "aiff", "mid", "wma", "ra", "vqf", "ape"].indexOf(nameSuffix) != -1) {
      return mp3Png
    }
    if (["avi", "wmv", "mpg", "mpeg", "mov", "rm", "ram", "swf", "flv", "mp4", "avi", "rm", "rmvb", "flv", "mpg", "mkv"].indexOf(nameSuffix) != -1) {
      return videoPng
    }
    switch ((nameSuffix || "").toLocaleLowerCase()) {
      case 'knowledge': src = knowledgePng; break;
      case 'directory': src = wenjianjiaPng; break;
      case 'doc':
      case 'docx': src = wordPng; break;
      case 'xls':
      case 'xlsx': src = excelPng; break;
      case 'document_map': src = mapPng; break;
      case 'document_flow': src = liuchengPng; break;
      case 'gif': src = gifPng; break;
      case 'png':
      case 'jpg':
      case 'jpeg': src = tupianPng; break;
      case 'txt': src = textPng; break;
      case 'ppt':
      case 'pptx': src = pptPng; break;
      case 'csv': src = csvPng; break;
      case 'pdf': src = pdfPng; break;
      case 'epub': src = dianzishuPng; break;
      case 'svg': src = svgPng; break;
      case 'rar':
      case 'arj':
      case 'z':
      case '7z':
      case 'cab':
      case 'zip': src = yasuoPng; break;
      case 'dwg':
      case 'dxf':
      case 'dws':
      case 'dwt': src = cadPng; break;
      case 'psd': src = psPng; break;
      case 'vsdx': src = visPng; break;
      case 'ofd': src = ofdPng; break;
      default: src = weizhiPng; break;
    }
  } else {
    switch (type) {
      case 'knowledge': src = knowledgePng; break;
      case 'directory': src = wenjianjiaPng; break;
      case 'document_html': src = txtPng; break;
      case 'document_xlsx': src = luckysheetPng; break;
      case 'document_map': src = mapPng; break;
      case 'document_flow': src = liuchengPng; break;
      case 'document_image': src = tupianPng; break;
      case 'document_txt': src = txtPng; break;
      case 'document_ppt': src = pptPng; break;
      case 'document_unrecognized': src = weizhiPng; break;
      case 'url_address': src = urlPng; break;
      case 'md': src = mdPng; break;
      case 'xmind': src = xmindPng; break;
      default: src = wenjianjiaPng; break;
    }
  }
  return src
}
</script>
<style lang="scss" scoped></style>